#ifndef _GAMEDEFINE_H_
#define _GAMEDEFINE_H_


#include "baseDefine.h"
#include "baseSingle.h"
#include "mathBase.h"
using namespace FOXSDK;

#define GETMAXHP( v , s , t , d ) ( v * 4 + s + t + d )

// map info

static const fint32	MAX_ITEM = 15;

static const fint32 MAX_NPC = 4096;

static const fint32	MAX_STONE = 1000000;

static const fint32	DEFAULT_JOINT_ATTACK = 20;

static const fint32	MAX_LEVELUP_POINT = 3;
static const fint32	MAX_LEVEL_CACHE = 256;

static const fint32	MAX_TEAM_CREATURE = 5;
static const fint32	MAX_TEAM_PET = 5;

static const fint32 MAX_MATERIAL = 5;

static const fint32	MAX_BATTLE_PLAYER = 5;
static const fint32	MAX_BATTLE_ENEMY = 10;
static const fint32	MAX_BATTLE_TURN = 300;

static const fint32	INVALID_ID = -1;

static const fint32	MAX_RANDOM_ENEMY = 100;

static const fint32	MAX_NPC_DATA = 1024;

static const fint32	MAX_CHAT_MSG = 128;
static const fint32	MAX_NAME = 32;
static const fint32	MAX_MOVE_PATH = 128;
static const fint32	MAX_MAP_PLAYER = 32;
static const fint32	MAX_MAP_NPC = 32;
static const fint32	MAX_MOVE_ERROR = 3;

static const freal32 DEFAULT_MOVE_SYNC_TIME = 2.2f;
static const fint32 DEFAULT_MOVE_SYNC_DIS = 18;

static const freal32 DEFAULT_MOVE_SPEED = 0.2f;
static const freal32 DEFAULT_MOVE_SPEED1 = 0.24f;
static const freal32 DEFAULT_MOVE_SPEED2 = 0.32f;

static const fint32	MAX_ROLE_BASESTATUS = 20;
static const fint32	MAX_ROLE_ATTR = 10;

static const fint32	MAX_ROLE_COUNT = 11;

extern fint32 GUEST_GUID;


#pragma pack (1)


enum SAAttributeType
{
	SAAT_NONE = 0,
	SAAT_EARTH,
	SAAT_WATER,
	SAAT_FIRE,
	SAAT_WIND,

	SAAT_ALL,

	SAAT_COUNT
};




enum SAStatusType
{
	SAST_NONE = 0,

	// 2.0
	SAST_ALL = 1,  
	SAST_POISON = 2,  // 毒
	SAST_PARALYSIS = 3, // 麻痹
	SAST_STONE = 4, // 石化
	SAST_CONFUSION = 5, // 混乱
	SAST_DRUNK = 6, // 酒醉
	SAST_SLEEP = 7, // 睡眠

	// 3.0
	SAST_TOXIC = 8, // 猛毒
	SAST_BARRIER = 9, // 壁障
	SAST_SILENCE = 10, // 沉默
	SAST_WEAK = 11 , // 虚弱
	SAST_DOWN = 12 , // 落马

	SAST_COUNT
};

enum SARoleColor
{
	SARC_COLOR0 = 0,
	SARC_COLOR1,
	SARC_COLOR2,
	SARC_COLOR3,
	SARC_COLOR4,
	SARC_COLOR5,
    
	SARC_COUNT
};


enum SARoleType
{
	SART_DOUDING = 0,
	SART_SAIYA,
	SART_HOUZI,
	SART_XIANDAN,
	SART_DASHU,
	SART_QIUZHANG,

	SART_DOUDINGMEI,
	SART_NAIYOU,
	SART_MEIZI,
	SART_FAJIA,
	SART_WUDAOJIA,
	SART_DAJIE,

	SART_COUNT
};



enum SABattleResultType
{
	SABRT_NEXT = 0,
	SABRT_WIN,
	SABRT_LOSE,
	SABRT_TIMEOUT,
    
	SABRT_COUNT
};


enum SABattleSessionType
{
	SABST_PVE = 0,
	SABST_PVP,
    
	SABST_COUNT
};


enum SABattleSessionCommandType
{
	SABSCT_ATTACK = 0,
	SABSCT_DEFENCE,
	SABSCT_MAGIC,
	SABSCT_STAY,
	SABSCT_ESCAPE,
    
	SABSCT_COUNT
};


enum SABattleSessionRow
{
	SABSR_UNDER = 0,
	SABSR_UP,
    
	SABSR_COUNT
};


enum SABattleSessionSide
{
	SABSS_SELF = 0,
	SABSS_ENEMY,
    
	SABSTF_COUNT
};


enum SABattleSessionResultType
{
	SABSRT_HP = 0,
	SABSRT_MP,
	SABSRT_HPMP,
	SABSRT_MISS,
	SABSRT_PARRY,
	SABSRT_KILL,
    
	SABSRT_COUNT
};




enum SARoleRidingType
{
	SARRT_NORMAL = 0,

	// 2.0
	SARRT_BRONTOSAURUS = 1, // 长颈龙
	SARRT_TIGER = 2, // 老虎

	// 3.0
	SARRT_BLUE_TYRANNOSAURUS = 3, // 蓝暴
	SARRT_RED_TYRANNOSAURUS = 4, // 红暴
	SARRT_ROBOT_TYRANNOSAURUS = 5, // 机暴
	SARRT_GRAY_ELEPHANT = 6, // 白象
	SARRT_GOLD_PTEROSAUR = 7, // 金飞
	SARRT_RED_DOG = 8, // 红狗
	SARRT_BLUE_DRAGON = 9, // 蓝人龙
	SARRT_GREEN_PANGOLIN = 10, // 绿穿山甲
	SARRT_RED_BEETLE = 11, // 红甲壳虫 
	SARRT_RED_ORANGUTAN = 12 , // 红猩猩

	SARRT_COUNT
};


enum SAMagicStatusType
{
	SAMST_NONE = 0,
	SAMST_ABSORB, // 吸收
	SAMST_REFLEX, // 反射
	SAMST_INVALID, // 无效

	SAMST_COUNT
};



enum SAMaterialType
{
	// 2.0
	SAMATLT_ROCK = 0, // 石
	SAMATLT_WOOD = 1, // 木
	SAMATLT_SKIN = 2, // 皮
	SAMATLT_BONE = 3, // 骨
	SAMATLT_THREAD = 4, // 线
	SAMATLT_SCALE = 5, // 鳞
	SAMATLT_LEAF = 6, // 叶
	SAMATLT_LAND = 7, // 土
	SAMATLT_CONCH = 8, // 贝
	SAMATLT_SHELL = 9, // 壳
	SAMATLT_CLAW = 10, // 爪
	SAMATLT_CRYSTAL = 11, // 水晶
	SAMATLT_FLOWER = 12, // 花
	SAMATLT_TOOTH = 13, // 牙
	SAMATLT_CLAY = 14, // 黏土

	SAMATLT_POISON = 20, // 毒
	SAMATLT_PARALYSIS = 21, // 麻痹
	SAMATLT_STONE = 22, // 石化
	SAMATLT_CONFUSION = 23, // 混乱
	SAMATLT_DRUNK = 24, // 酒醉 
	SAMATLT_SLEEP = 25, // 睡眠
	SAMATLT_CURE = 26, // 回复
	SAMATLT_RELIVE = 27, // 复活

	SAMATLT_LOYALA = 30, // 忠A
	SAMATLT_LOYALB = 31, // 忠B


	SAMATLT_EARTH = 50, // 地
	SAMATLT_WATER = 51, // 水
	SAMATLT_FIRE = 52, // 火
	SAMATLT_WIND = 53, // 风

	SAMATLT_ACORN = 100, // 橡树果
	SAMATLT_BEANS = 101, // 豆
	SAMATLT_CARBON = 102, // 碳
	SAMATLT_SUGAR = 103, // 砂糖
	SAMATLT_VANILLA = 104, //香草
	SAMATLT_MEAT = 105, // 肉
	SAMATLT_FISH = 106, // 鱼
	SAMATLT_SKEWERS = 107, // 串
	SAMATLT_EGG = 108, // 卵
	SAMATLT_DRINKWATER = 109, // 饮用水
	SAMATLT_SALT = 110, // 盐
	SAMATLT_SHRIMP = 111, // 虾
	SAMATLT_CRAB = 112, // 螃蟹
	SAMATLT_OCTOPUS = 113, // 章鱼
	SAMATLT_GARLIC = 114, // 大蒜
	SAMATLT_ONIONS = 115, // 葱
	SAMATLT_PEPPER = 116, // 胡椒
	SAMATLT_MUSHROOM = 117, // 香菇
	SAMATLT_RICE = 118, // 米
	SAMATLT_SEAWEED = 119, // 海草
	SAMATLT_APPLE = 120, // 苹果
	SAMATLT_LIZARD = 121, // 蜥蜴
	SAMATLT_STARFISH = 122, // 海星
	SAMATLT_FROG = 123, // 青蛙
	SAMATLT_GINGER = 124, // 生姜
	SAMATLT_ASPARAGUS = 125, // 芦笋
	SAMATLT_CARROTS = 126, // 红萝卜
	SAMATLT_POTATO = 127, // 马铃薯
	SAMATLT_PEAR = 128, // 梨
	SAMATLT_CHERRY = 129, // 樱桃
	SAMATLT_BAMBOO = 130, // 竹笋
	SAMATLT_GRAPES = 131, // 葡萄
	SAMATLT_CEREALS = 132, // 谷
	SAMATLT_CABBAGE = 133, // 包心菜
	SAMATLT_CHILI = 134, // 青椒
	SAMATLT_TOMATOE = 135, // 番茄
	SAMATLT_EGGPLANT = 136, // 茄子
	SAMATLT_CUCUMBER = 137, // 小黄瓜
	SAMATLT_PEACH = 138, // 桃子
	SAMATLT_STRAWBERRY = 139, // 草莓
	SAMATLT_OIL = 140, // 油
	SAMATLT_ORANGE = 141, // 橘子
	SAMATLT_PERSIMMON = 142, // 柿子
	SAMATLT_CHINESECABBAGE = 143, // 白菜
	SAMATLT_PUMPKIN = 144, // 南瓜
	SAMATLT_MSG = 145, // 味精
	SAMATLT_SOUPSTOCK = 146 , // 高汤

	// 3.0
	SAMATLT_IRON = 200, // 铁
	SAMATLT_COPPER = 201, // 铜
	SAMATLT_DIAMOND = 202, // 钻石
	SAMATLT_RUBY = 203, // 红宝石
	SAMATLT_SAPPHIRE = 204, // 蓝宝石
	SAMATLT_EMERALD = 205, // 绿宝石
	SAMATLT_TOPAZ = 206, // 黄宝石
	SAMATLT_PEARL = 207, // 珍珠


	SAMATLT_SP0 = 300, // 恒冰结晶
	SAMATLT_SP1 = 301, // 暴龙的尖牙
	SAMATLT_SP2 = 302, // 蝎子的刺
	SAMATLT_SP3 = 303, // 巨象的骨头
	SAMATLT_SP4 = 304, // 海龙的骨头
	SAMATLT_SP5 = 305, // 龙蜥的皮
	SAMATLT_SP6 = 306, // 雷龙的骨头
	SAMATLT_SP7 = 307, // 老虎的骨头
	SAMATLT_SP8 = 308, // 人鱼的皮

	SAMATLT_ALCHEMY = 309, // 炼金粉末

	SAMATLT_SP20 = 320, // 雷尔一
	SAMATLT_SP21 = 321, // 雷尔二
	SAMATLT_SP22 = 322, // 雷尔三
	SAMATLT_SP23 = 323, // 海盗一
	SAMATLT_SP24 = 324, // 海盗二
	SAMATLT_SP25 = 325, // 海盗三
	SAMATLT_SP26 = 326, // 奶牛一
	SAMATLT_SP27 = 327, // 奶牛二
	SAMATLT_SP28 = 328, // 奶牛三
	SAMATLT_SP29 = 329, // 忍者一
	SAMATLT_SP30 = 330, // 忍者二
	SAMATLT_SP31 = 331, // 忍者三
	SAMATLT_SP32 = 332, // 绅士一
	SAMATLT_SP33 = 333, // 绅士二
	SAMATLT_SP34 = 334, // 绅士三


};



enum SANpcType
{
	SANT_WARPMAN = 0,
	SANT_WARP,
	SANT_SAVEPOINT,

	SANT_FIGHT,
	SANT_QUEST,
	SANT_SHOP,
	SANT_MAN,
	SANT_HEALER,
	SANT_CHARM,
	SANT_PETSHOP,
	SANT_SIGNBOARD,
	SANT_DENGON,
	SANT_POOLITEMSHOP,
	SANT_TRANSMAN,

	SANT_ITEMCHANGE,
	SANT_PROFESSIONSHOP,
	SANT_FREEPETSKILL,
	SANT_PETSKILLSHOP,
	SANT_PETFUSION,
	SANT_WINDOWMAN,
	SANT_LIMITSHOP,
	SANT_TIMEMAN,
	SANT_LUCKYMAN,
	SANT_FAMILYMAN,
	SANT_BANKMAN,
	SANT_GAMBLEBANK,

	SANT_COUNT
};

enum SANpcState
{
	SANS_ALREADY = 0,
	SANS_DENIED,

	SANS_COUNT
};

enum SANpcMode
{
	SANM_NULL = -1,
	SANM_MODE0 = 0,
	SANM_MODE1,
	SANM_MODE2,
	SANM_MODE3,
	SANM_COUNT,
};

enum NpcDieMode
{
	SANDM_DIE = 0,
	SANDM_WARP,

	SANDM_COUNT
};

enum SAQuestActionType
{
	SAQAT_MESSAGE = 0,
	SAQAT_ACCEPT,
	SAQAT_REQUEST,
	SAQAT_CLEAN,

	SAQAT_COUNT
};

enum SAHealMode
{
	SAHM_ALL = 0,
	SAHM_SELF,
	SAHM_PET,

	SAHM_COUNT
};




enum SACreatureAttributeType
{
	SACAT_VITALITY = 0, 
	SACAT_STRENGTH,
	SACAT_TOUGHNESS,
	SACAT_DEXTERITY,

	SACAT_COUNT = 4
};


enum SACreatureMoveDirection
{
	SACMD_NORTH = 3,
	SACMD_SOUTH = 7,
	SACMD_WEST = 1,
	SACMD_EAST = 5,
	SACMD_NORTHWEST = 2,
	SACMD_NORTHEAST = 4,
	SACMD_SOUTHWEST = 0,
	SACMD_SOUTHEAST = 6,

	SACMD_COUNT = 8
};


enum SAEquipType
{
	SAET_HEAD = 0,
	SAET_BODY,
	SAET_RIGHT,
	SAET_LEFT,
	SAET_GLOVE,
	SAET_BELT,
	SAET_SHOES,
	SAET_RING1,
	SAET_RING2,

	SAET_COUNT
};




enum SAItemType
{
	SAIT_FIST = 0,
	SAIT_AXE,
	SAIT_CLUB,
	SAIT_SPEAR,
	SAIT_BOW,
	SAIT_SHIELD,
	SAIT_HELM,
	SAIT_ARMOUR,

	SAIT_BRACELET = 8,
	SAIT_MUSIC,
	SAIT_NECKLACE,
	SAIT_RING,
	SAIT_BELT,
	SAIT_EARRING,
	SAIT_NOSERING,
	SAIT_AMULET,

	SAIT_OTHER = 16,	// 羽毛啥的
	SAIT_BOOMERANG,		// 回旋标
	SAIT_BOUNDTHROW,	// 投掷斧头
	SAIT_BREAKTHROW,	// 投掷石
	SAIT_DISH = 20,		// 食物
	SAIT_METAL,
	SAIT_JEWEL,
	SAIT_WARES,			//货物

	SAIT_WBELT,			//腰带
	SAIT_WSHIELD,		//盾
	SAIT_WSHOES,		//鞋子

	SAIT_WGLOVE,		//手套
	
	SAIT_ALCHEMIST = 30 ,
	SAIT_PETHELMET = 31,
	SAIT_WINGARMOR,
	SAIT_PETTOOTH,

	SAIT_COUNT
};


enum SAUseItemType
{
	SAUIT_PLAYER = 0,
	SAUIT_PET,
	SAUIT_TEAM,


	SAUIT_COUNT
};


enum SAFieldType
{
	SAFT_ALL,		// 全部
	SAFT_BATTLE,    // 战斗中使用
	SAFT_MAP,		// 地图

	SAFT_COUNT
};

enum SAMagicTargetType
{
	SAMGCTT_MYSELF = 0,		
	SAMGCTT_OTHER,			
	SAMGCTT_ALLMYSIDE,		
	SAMGCTT_ALLOTHERSIDE,	
	SAMGCTT_ALL,			
	SAMGCTT_NONE,			
	SAMGCTT_OTHERWITHOUTMYSELF,
	SAMGCTT_WITHOUTMYSELFANDPET,
	SAMGCTT_WHOLEOTHERSIDE,

	SAMGCTT_SINGLE,            // 针对敌方的某一人
	SAMGCTT_ONE_ROW,           // 针对敌方的某一列
	SAMGCTT_ALL_ROWS,          // 针对敌方的所有人

	SAMGCTT_COUNT
};


enum SAPetSkillTargetType
{
	SAPSTT_MYSELF = 0,		
	SAPSTT_OTHER,		
	SAPSTT_ALLMYSIDE,		
	SAPSTT_ALLOTHERSIDE,
	SAPSTT_ALL,		
	SAPSTT_NONE,			
	SAPSTT_OTHERWITHOUTMYSELF,
	SAPSTT_WITHOUTMYSELFANDPET, 

	SAPSTT_COUNT
};



enum SAActionType
{
	SAACTT_ATTACK = 0,
	SAACTT_HAND = 6,
	SAACTT_FALL = 2,
	SAACTT_HURT = 1,
	SAACTT_DEFENCE = 10,
	SAACTT_CRY = 9,
	SAACTT_ANGER = 8,
	SAACTT_SIT = 5,
	SAACTT_STAND = 3,
	SAACTT_THROW = 12,
	SAACTT_HEAD = 11,
	SAACTT_MOVE = 4,
	SAACTT_HAPPY = 7,

	SAACTT_COUNT = 13

};

struct MapGridID
{
	fint16 x;
	fint16 y;
    
	MapGridID() :
	x( INVALID_ID ) , y( INVALID_ID )
	{
        
	}
    
	MapGridID( fint32 x , fint32 y )
	{
		this->x = (fint16)x;
		this->y = (fint16)y;
	}
    
	bool operator < ( const MapGridID& id ) const
	{
		return ( (y << 16) + x < (id.y << 16) + id.x );
	}
    
	bool operator == ( const MapGridID& id ) const
	{
		return ( y == id.y && x == id.x );
	}
    
	bool operator != ( const MapGridID& id ) const
	{
		return ( y != id.y || x != id.x );
	}
    
	fint32 distance( const MapGridID& id ) const
	{
		return (id.x - x) * (id.x - x) + (id.y - y) * (id.y - y);
	}
    
    fint32 distanceGrid( const MapGridID& id ) const
	{
        int dx = abs( id.x - x );
        int dy = abs( id.y - y );
        
		return dx > dy ? dx : dy;
	}
};


struct MapPos
{
	fint32		MapID;
	MapGridID	Grid;
    
	MapPos()
    :	MapID( INVALID_ID )
	{
        
	}
};



typedef list< MapGridID > MapGridIDList;
typedef list< MapGridID >::iterator MapGridIDListIter;

typedef vector< MapGridID > MapGridIDVector;
typedef vector< MapGridID >::iterator MapGridIDVectorIter;

typedef vector< string > StringVector;
typedef vector< string >::iterator StringIter;

typedef vector< fint32 > IntVector;
typedef vector< fint32 >::iterator IntIter;


struct CreatureFightCommand
{
	fbyte	Type;
	fbyte	TargetRow;
	fbyte	TargetIndex;
	fbyte	unknow1;
};


struct BattleSessionCommand
{
	CreatureFightCommand    cmd;
    
	fbyte                   Side;
	fbyte                   Row;
	fbyte                   Index;
	fbyte                   unknow1;
};


struct BaseData
{
	fint16		HP;
	fint16		MAXHP;
	fint16		MP;
	fint16		MAXMP;
    
	fint16		Attack;
	fint16		Defence;
	fint16		Quick;
	fint16		Charm;
    
	fbyte		Earth;
	fbyte		Water;
	fbyte		Fire;
	fbyte		Wind;
    
	BaseData()
    :	HP( 0 ) , MAXHP( 0 ) , MP( 0 ) , MAXMP( 0 ) ,
    Attack( 0 ) , Defence( 0 ) , Quick( 0 ) , Charm( 0 ) ,
    Earth( 0 ) , Water( 0 ) , Fire( 0 ) , Wind( 0 )
	{
        
	}
};


struct CreatureData
{
	BaseData	Base;
    
	fint32		ID;
	fint32		ActionID;
    
	fbyte		Name[ MAX_NAME ];
    
	fbyte		Role;
	fbyte		Color;
	fbyte		Eye;
	fbyte		Mouth;
    
    fbyte       RidingPet;
    fbyte       WeaponType;
    fbyte       unknow1;
    fbyte       unknow2;
    
	fint16		Vitality;
	fint16		Strength;
	fint16		Toughness;
	fint16		Dexterity;
    
	fint16		Type;
	fint16		DP;
    
	fint32		EXP;
	fint32		NEXTEXP;
    
	fint16		LevelUpPoint;
	fubyte		Level;
	fubyte		LevelPRO;
    
    
	CreatureData()
    : ID( INVALID_ID ) , ActionID( INVALID_ID ) ,
    Role( 0 ) , Color( 0 ) , Eye( 0 ) , Mouth( 0 ) ,
    Vitality( 0 ) , Strength( 0 ) , Toughness( 0 ) , Dexterity( 0 ) ,
    Type( 0 ) , DP( 0 ) , EXP( 0 ) , NEXTEXP( 0 ) ,
    Level( 0 ) , LevelPRO( 0 ) , LevelUpPoint( 0 ) ,
    RidingPet( 0 ) , WeaponType( 0 )
	{
		memset( Name , 0 , MAX_NAME );
	}
};


struct PetData
{
	freal32		LevelUpPoint;
    
	freal32		Vitality;
	freal32		Strength;
	freal32		Toughness;
	freal32		Dexterity;
    
	PetData()
    :	LevelUpPoint( 0.0f ) ,
    Vitality( 0.0f ) , Strength( 0.0f ) , Toughness( 0.0f ) , Dexterity( 0.0f )
	{
        
	}
};


struct PetSynData
{
	CreatureData	Data;
    
	fint16			ID;
	fint16			Photo;
};


struct CreatureFightData
{
	BaseData	Base;
    
	fint16		Poison;
	fint16		Paralysis;
	fint16		Sleep;
	fint16		Stone;
	fint16		Drunk;
	fint16		Confusion;
    
	fint16		Rare;
	fint16		Critical;
	fint16		Counter;
	fint16		Type;
    
	fint32		JointAttack;
    
	CreatureFightData()
    :	Poison( 0 ) , Paralysis( 0 ) ,
    Sleep( 0 ) , Stone( 0 ) , Drunk( 0 ) , Confusion( 0 ) ,
    Rare( 0 ) , Critical( 0 ) , Counter( 0 ) , Type( INVALID_ID ) , JointAttack( DEFAULT_JOINT_ATTACK )
	{
        
	}
};


struct CreatureFightStatus
{
	fint32 Status;
	fbool Fall;
};


struct QuestAction
{
	SAQuestActionType	Type;
    
	fint32			EventNo;
	fint32			EventNow;
	fint32			EventEnd;
	fint32			EventDel;
    
	fint32			CleanFlg;
    
	fint32			PointID;
	fint32			PointX;
	fint32			PointY;
    
	fint32			Item;
	fint32			NowLevel;
	fint32			PetLevel;
	fint32			PetID;
    
	fint32			WarpID;
	fint32			WarpX;
	fint32			WarpY;
    
	fint32			AddStone;
	fint32			DelStone;
    
    
	IntVector		AddItem;
	IntVector		DelItem;
	IntVector		GetItem;
	IntVector		GetRandItem;
    
    
	string			AcceptMsg;
	string			ThanksMsg;
	string			StopMsg;
	string			EndStopMsg;
	string			RequestMsg;
	string			NoStopMsg;
	string			KeyWord;
	string			StoneLessMsg;
	string			CleanMainMsg;
	string			CleanFlgMsg;
    
    
	QuestAction()
	{
        
	}
    
};

typedef vector< QuestAction > QuestActionVector;
typedef vector< QuestAction >::iterator QuestActionIter;


struct NpcSelectData
{
	fint32	WarpID;
	fint32	WarpX;
	fint32	WarpY;
    
};

typedef vector< NpcSelectData > NpcSelectDataVector;
typedef vector< NpcSelectData >::iterator NpcSelectDataIter;


struct NpcCreateData
{
    MapPos      Pos;
    MathRect    BornCenterRect;
    MathRect    BornCornerRect;
    MathRect    MoveCenterRect;
    MathRect    MoveCornerRect;
    
    fint32      Num;
    fint32      Image;
    fint32      Direction;
    fint32      Time;
    fint32      Fly;
    fint32      ItemNum;
    
    fint32      Action;
    fint32      Name;
    fint32      IgnoreInvincible;
    
	
    NpcCreateData()
	{
	}
    
};

struct NpcTemplateData
{
    string  Template;
    string  Name;
    string  Fun;
    string  ImgName;
    
    fint32  NoBody;
    fint32  NoSee;
    fint32  Type;
    fint32  HP;
    fint32  MP;
    fint32  Str;
    fint32  Tough;
    fint32  LoopTime;
    fint32  Fly;
    fint32  ItemNum;
    
    NpcTemplateData()
    {
    }
};

struct NpcARGData
{
    NpcARGData()
    {
        
    }
    
    
};


typedef vector< NpcCreateData* > NpcCreateDataVector;
typedef vector< NpcCreateData* >::iterator NpcCreateDataVectorIter;

typedef vector< NpcTemplateData* > NpcTemplateDataVector;
typedef vector< NpcTemplateData* >::iterator NpcTemplateDataVectorIter;

typedef map< string , NpcTemplateData* > NpcTemplateDataMap;
typedef map< string , NpcTemplateData* >::iterator NpcTemplateDataMapIter;

typedef vector< NpcARGData* > NpcARGDataVector;
typedef vector< NpcARGData* >::iterator NpcARGDataVectorIter;


class AchievementData
{
public:
    
	fint32	money;
	fint32	quest;
    
    
    
};



struct PlayerInfo
{
	fint32		GUID;
	fbyte		Name[ MAX_NAME ];
    
	fbyte		Role;
	fbyte		Color;
    fbyte       RidingPet;
    fbyte       WeaponType;
    
	fubyte		Level;
	fubyte		LevelPRO;
	fint16		Unknow1;
    
	fint16		HP;
	fint16		MAXHP;
	fint16		MP;
	fint16		MAXMP;
    
	MapPos		Pos;
};


struct ItemInfo
{
	fbyte	Item;
	fbyte	Type;
	fbyte	Unknow1;
	fbyte	Unknow2;
    
	fint32	ID;
	fint32	Image;
	fint32	Sell;
	fint32	Num;
    
	fbyte	Px;
	fbyte	Py;
	fbyte	i;
	fbyte	n;
};


struct NpcInfo 
{
	fint32	Texture;
    
	fint16	ID;
	fbyte	Px;
	fbyte	Py;
    
	fint16	X;
	fint16	Y;
    
	fbool	Fall;
    
	fbyte	Name[ MAX_NAME ];
};


static SACreatureMoveDirection GetDirection( const MapGridID& pos1 , const MapGridID& pos2 )
{
	int x = pos1.x - pos2.x;
	int y = pos1.y - pos2.y;
    
	SACreatureMoveDirection direction = SACMD_COUNT;
    
	if ( x > 0 && y > 0 )
		direction = SACMD_SOUTHEAST;
	else if ( x > 0 && y == 0 )
		direction = SACMD_EAST;
	else if ( x > 0 && y < 0 )
		direction = SACMD_NORTHEAST;
	else if ( x == 0 && y < 0 )
		direction = SACMD_NORTH;
	else if ( x < 0 && y < 0 )
		direction = SACMD_NORTHWEST;
	else if ( x < 0 && y == 0 )
		direction = SACMD_WEST;
	else if ( x < 0 && y > 0 )
		direction = SACMD_SOUTHWEST;
	else if ( x == 0 && y > 0 )
		direction = SACMD_SOUTH;
    
	return direction;
    
}


#pragma pack ()

#endif


